= new queue list
(); Model = new SuggestTabelModel (cellData, headers); table = new JTable (model); jscrollPane = new JScrollPane (table); jscrollPane. setPreferredSize (new Dimension (340,270); enterButton = new JButton ("add menu"); enterButton. setPreferredSize (new Dimension (); add (jscrollPane); add (enterButton); enterButton. addActionListener (this); // The Center shows DefaultTableCellRenderer r = new DefaultTableCellRenderer (); r. setHorizontalAlignment (JLabel. CENTER); t
/** To change this template, choose tools | templates* And open the template in the editor.*/Package comm. swingcomm;
Import javax. Swing. jtable;Import javax. Swing. Table. tablecolumn;
/*** Jtable control public control class* @ Author http://www.my400800.cn*/Public class jtablecomm {
/** * Hide the specified column of the specified jtable * @ Param table specify jtable * @ Param column specify column */ tablecolumn Tc = table. gettableheader (). getcolumnmodel ().
makeconnection () throws exception {Class. forname (mydriver). newinstance ();Myconn = drivermanager. getconnection (myurl );}Public abstract void cleanup () throws exception;Public void takedown () throws exception {Cleanup ();Myconn. Close ();}}Create a dbbean file in the same way. The dbbean file code is as follows:Package test;
Import Java. SQL. resultset; Import Java. SQL. statement; // dbbean inherits data from sqlbean for data retrieval public class dbbean extends sqlbean {
String My
CListCtrl the properties of the column can be obtained by using the bool Clistctrl::getcolumn (int ncol, lvcolumn* pcolumn), ncol the column ordinal to obtain the property value, Pcolumn to Lvcolumn The pointer to the structure body. The UINT mask in the lvcolumn structure, as input, determines which properties to return, and if the mask value contains Lvcf_text, the first address pointer of the string cache needs to be placed into the LPTSTR psztext
= null;JTable table= New JTable (p,n);Table.setpreferredscrollableviewportsize (New Dimension (550,30));Table.setautoresizemode (Jtable.auto_resize_subsequent_columns);Using the Getcolumnmodel () method in JTable to obtain the Tablecolumnmodel object, and then using the GetColumn () method defined by the Tablecolumnmodel interface to fetch the TableColumn object, You can control the width of a field by using the Setpreferredwidth () method of this obj
Reading the content of an EXCEL table with C ++ is a very troublesome task. Today I read the content of the EXCEL table with CStringArray mentioned in "VC ++", which is really good. This format is usually used to convert an EXCEL file into a CSV file as a format for data interaction between different programs ). Then, use the C ++ program to read CSV files. There are two main classes: class CRow{Private:CStringArray * _ row;Public:CRow (CStringArray * row );Int getColumnCount (void );CString
the beginning. This function returns a long integer that indicates the row number of the first highlighted row starting from rownumber. If the request fails, 0 is returned.
7. Scroll rows
If a row of data is inserted at the end of datawindow, and the current row is in the center of datawindow, This insertion may not be noticed by users. To change this situation, you can scroll to the end of datawindow to discover new changes. To scroll a row, you can use the scrolltorow () function.Syntax forma
. setselectionforeground (color. White); you can also hide the cell's square coordinate line, as shown below:Example: Table. setshowhorizontallines (false); table. setshowverticallines (false );Figure A shows a jtable that hides its horizontal coordinate line.
Figure
Column widthThe jtable component has several table-controlled features.Class and interface. Tablecolumn keeps track of the column width and adjusts the column size, including the maximum and minimum widths. Tablecolumnmodel managesT
// Find the row that best matches the input data in the drop-down data window
If ls_type = "Number" then
Do until ll_count> child. rowcount ()
Ll_mthrow = Child. getitemnumber (ll_count, ls_col_name)
If left (string (ll_mthrow), Len (ls_search) = ls_search then
Ll_searchrow = ll_count
Exit
Else
Ll_count = ll_count + 1
End if
Loop
Else
Do until ll_count> child. rowcount ()
Ll_mthtext = Child. getitemstring (ll_count, ls_col_name)
If left (FIG, Len (ls_search) = ls_search then
Ll_searchrow = ll_c
.
TableColumnModel manages the TableColumns set and column selection. To set a column
To set a reference for the model of the table column. Then, obtain the desired
TableColumn and call its setPreferredWidth () method:TableColumncolumn = table. getColumnModel (). getColumn (0 );Column. setPreferredWidth (100 );
When you drag and drop a column, the column index does not change. The getColumn (0) method will
");
ComboBox. additem ("Logistics Department ");
ComboBox. additem ("Finance Department ");
// Tablecolumn is used to edit attributes of a column in a table.
Tablecolumn = table. getcolumn ("Department ");
// Use the setcelleditor () method in the tablecolumn class to set the cell Editor
// The defaultcelleditor class can set cells in the table as drop-down boxes.
Tablecolumn. setcelleditor (NewDefaultcelleditor (ComboBox ));
// Defaulttablecellre
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.